<?php session_start(); 
if(!empty($_POST['idProduct'])){
	require_once('3_PHP/connexionPDO.php');
	require_once('3_PHP/fonctionPDO.php');
	$result=getProduct($pdo,$_POST['idProduct']);
	$_SESSION['products'][$_POST['idProduct']] ++;
}
?>
<!DOCTYPE html>
<html>
	<!-- HEAD -->
<?php include ('header.php') ?>
<?php include_once('3_PHP/fonctionPDO.php') ?>



	<!-- BODY -->
	<body>
		<!-- NAVIGATION -->
<?php include ('navigation.php') ?>
		
		
		
		<!-- MAIN -->
		<div id="main_body">
			<h1>PRODUCTS</h1>
			<h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
				Aliquam et nisl orci, nec interdum eros. Nunc a odio 
				suscipit neque aliquam vestibulum. Nullam sed diam est, 
				molestie tristique ipsum. Curabitur rutrum, sapien eu dictum 
				vehicula, metus lectus lobortis mi, nec tincidunt orci sem eu dolor. 
				Nunc quis mi nec ligula vehicula bibendum nec sed mauris.
			</h4>
			
			
			<ul id="product_list">
			<?php 
				require_once('3_PHP/connexionPDO.php');			
				$result=getAllproducts($pdo);
				foreach($result as $row) {
			?>
					<li class="rectangle_container">
						<div class="product_list_item_image">
							<img src="data:image/gif;base64,<?php echo $row->imgbase64 ?>" alt="<?php echo $row->title ?>">
						</div>
						<div class="product_list_item_description">
							<h1><?php echo $row->title?></h1>
							<h4><?php echo $row->description ?></h4>
							<div class="product_price">
								Price: <?php echo $row->price ?>
							</div>
							<div class="product_price">
								Stock: <?php echo $row->number ?>
							</div>
							<div class="product_buy_button">
								<form method="post">
									<input type="hidden" name="idProduct" value="<?php echo $row->id; ?>">
									<button class="bouton_buy" type="button">Buy</button>
								</form>
							</div>
						</div>
					</li>
				<?php } ?>
			</ul>
		</div>



		<!-- FOOTER -->
<?php include('footer.php') ?>
</html>